#include "pch.hpp"

#include "BallType.h"

static sf::Image images[BallType::Count+3];
static sf::Sprite sprites[BallType::Count+3];
static bool loaded = false;

void InitBallSprites()
{
	loaded = true;
	std::string strTmp;
	for (int i = 0 ; i < BallType::Count + 3 ; ++i)
	{
		std::stringstream ssFormat;
		if (i < BallType::Count)
		{
			ssFormat << "data/snake_ball" << (i + 1) << ".png";
			images[i].LoadFromFile(ssFormat.str());
			sprites[i].SetImage(images[i]);
		}
		else if (i == BallType::BonusSlowMo)
		{
			ssFormat << "data/slow_time.png";
			images[i].LoadFromFile(ssFormat.str());
			sprites[i].SetImage(images[i]);
		}
		else if (i == BallType::BonusFreeze)
		{
			ssFormat << "data/time_freeze.png";
			images[i].LoadFromFile(ssFormat.str());
			sprites[i].SetImage(images[i]);
		}
	}
}

sf::Image& GetBallImage(BallType::Type type)
{
	if (type == BallType::Count)
		std::cout << "[GetBallImage] Zla wartosc, glupcze\n";
	if(!loaded)
		std::cout << "[GetBallImage] Najpierw zaladuj obrazki, glupcze\n";
	return images[type];
}
